package com.eos.orm.mybatis.dao.impl;

import java.util.ArrayList;
import java.util.List;

import org.apache.ibatis.session.SqlSession;

import com.eos.orm.mybatis.dao.SysProductMapper;
import com.eos.orm.mybatis.model.SysProduct;
import com.eos.orm.mybatis.model.SysProductExample;
/**
 * sys_product系统产品名称表CURD操作
 * @author sz
 *
 */
public class SysProductMapperImpl extends AbstractSqlSessionFactory implements
		SysProductMapper {

	public int countByExample(SysProductExample example) {
		return 0;
	}

	public int deleteByExample(SysProductExample example) {
		return 0;
	}

	public int deleteByPrimaryKey(Integer id) {
		SqlSession session = sqlSessionFactory.openSession();
		try{
			SysProductMapper mapper = session.getMapper(SysProductMapper.class);
			mapper.deleteByPrimaryKey(id);
			session.commit();
			mapper = null;
		}catch(Exception e){
			System.out
			.println("com.eos.orm.mybatis.dao.impl.SysProductMapperImpl.deleteByPrimaryKey throws exception:"
					+ e.getMessage());
			return -1;
		}finally{
			session.close();
		}
		return 0;
	}

	public int insert(SysProduct record) {
		SqlSession session = sqlSessionFactory.openSession();
		try{
			SysProductMapper mapper = session.getMapper(SysProductMapper.class);
			mapper.insert(record);
			session.commit();
			mapper = null;
		}catch(Exception e){
			System.out
			.println("com.eos.orm.mybatis.dao.impl.SysProductMapperImpl.insert throws exception:"
					+ e.getMessage());
			return -1;
		}finally{
			session.close();
		}
		return 0;
	}

	public int insertSelective(SysProduct record) {
		return 0;
	}

	public List<SysProduct> selectByExample(SysProductExample example) {
		List<SysProduct> templist = new ArrayList<SysProduct>();
		SqlSession session = sqlSessionFactory.openSession();
		try{
			SysProductMapper mapper = session.getMapper(SysProductMapper.class);
			templist = mapper.selectByExample(example);
			mapper = null;
		}catch(Exception e){
			System.out
			.println("com.eos.orm.mybatis.dao.impl.SysProductMapperImpl.selectByExample throws exception:"
					+ e.getMessage());
		}finally{
			session.close();
		}
		return templist;
	}

	public SysProduct selectByPrimaryKey(Integer id) {
		SqlSession session = sqlSessionFactory.openSession();
		try{
			SysProductMapper mapper = session.getMapper(SysProductMapper.class);
			return mapper.selectByPrimaryKey(id);
		}catch(Exception e){
			System.out
			.println("com.eos.orm.mybatis.dao.impl.SysProductMapperImpl.selectByPrimaryKey throws exception:"
					+ e.getMessage());
		}finally{
			session.close();
		}
		return null;
	}

	public int updateByExample(SysProduct record, SysProductExample example) {
		return 0;
	}

	public int updateByExampleSelective(SysProduct record,
			SysProductExample example) {
		return 0;
	}

	public int updateByPrimaryKey(SysProduct record) {
		return 0;
	}

	public int updateByPrimaryKeySelective(SysProduct record) {
		SqlSession session = sqlSessionFactory.openSession();
		try{
			SysProductMapper mapper = session.getMapper(SysProductMapper.class);
			mapper.updateByPrimaryKeySelective(record);
			session.commit();
			mapper = null;
		}catch(Exception e){
			System.out
			.println("com.eos.orm.mybatis.dao.impl.SysProductMapperImpl.updateByPrimaryKeySelective throws exception:"
					+ e.getMessage());
			return -1;
		}finally{
			session.close();
		}
		return 0;
	}

}
